﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using AMS.DD35.Common;
using AMS.Core.Services;
using AMS.DD35.DbAccess;
using AMS.DD35.Common.Data;

namespace AMS.DD35.ServiceLib.Services
{
    public class CharacterService : ICharacterService
    {
        private ICharacterConnector _character;
        private ISessionService _session;

        public CharacterService(ICharacterConnector character, ISessionService sessionService)
        {
            this._character = character;
            this._session = sessionService;
        }

        public CharacterData GetCharacterData(long characterID, object sessionVariable)
        {
            // sessionID checked by Master

            return _character.GetCharacterData(characterID);
        }

        public void SaveCharacter(CharacterData characterData, object sessionVariable)
        {
            // sessionID checked by Master

            _character.SaveCharacter(characterData); 
        }

        public IEnumerable<CharacterData> GetCharactersData(object sessionVariable)
        {
            return _character.GetCharacters(_session.ResolveIdentifier(sessionVariable));
        }
    }
}
